/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package data;

import java.math.BigInteger;
import java.util.LinkedList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Agnieszka
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Card implements Cloneable {

    @XmlTransient
    private BigInteger secretR;
    private BigInteger r;
    private Integer number = 0;
    private List<Vote> votes = new LinkedList<Vote>();

    public BigInteger getR() {
        return r;
    }

    public void setR(BigInteger r) {
        this.r = r;
    }

    public BigInteger getSecretR() {
        return secretR;
    }

    public void setSecretR(BigInteger secretR) {
        this.secretR = secretR;
    }

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    public List<Vote> getVotes() {
        return votes;
    }

    public void setVotes(List<Vote> votes) {
        this.votes = votes;
    }

    public void generate(Integer number) {
        for (Integer i = 0; i < number; i++) {
            getVotes().add(new Vote(i));
        }
    }

    @Override
    protected Card clone() {
        try {
            Card card = (Card) super.clone();
            List<Vote> list = new LinkedList<Vote>();
            for(Vote v : getVotes()) {
                list.add(v.clone());
            }
            card.setVotes(list);
            return card;
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            return null;
        }
    }
}
